// 系统设置相关 API
import request from '@/utils/request';

import { ApiResponse, PageParams, PageResult } from '@/types/common';
import { SystemSettings, OperationLog } from '@/types/system';

export const settingsApi = {
  // 获取系统设置
  getSettings: (): Promise<ApiResponse<SystemSettings>> =>
    request.get('/settings'),

  // 更新系统设置
  updateSettings: (data: Partial<SystemSettings>): Promise<ApiResponse<SystemSettings>> =>
    request.put('/settings', data),

  // 获取操作日志
  getOperationLogs: (params: PageParams): Promise<ApiResponse<PageResult<OperationLog>>> =>
    request.get('/settings/operation-logs', params),

  // 系统备份
  backup: (): Promise<ApiResponse<{ downloadUrl: string }>> =>
    request.post('/settings/backup'),

  // 清理系统缓存
  clearCache: (): Promise<ApiResponse<void>> =>
    request.post('/settings/clear-cache'),
}; 